package list

import (
	"net/http"
	"fmt"
	"io/ioutil"
	"encoding/json"
	"gogl/config"
)

type SongData struct{
	Title string `json:"name"`
	Artist string `json:"alias"`
	Album string `json:"album__name"`
	Url string	`json:"mp3_url"`
}
var Songdatas  []*SongData

func  SetNet(){
	req,_ := http.NewRequest("GET",config.BaseUrl+"api/song/?expand=album",nil)
	req.Header.Set("Content-Type", "application/json")
	client := http.DefaultClient
	resp,err := client.Do(req)
	if err != nil{
		fmt.Println("网络错误",err)
	}
	retbody := resp.Body
	defer retbody.Close()
	if resp.StatusCode != 200 {
		fmt.Errorf("HTTP Response Error %d\n",resp.StatusCode)
	}
	retbodyr, _ := ioutil.ReadAll(retbody)
	json.Unmarshal(retbodyr,&Songdatas)
}